Closed Bug 1899882 Opened 1 year ago Closed 1 year ago

Invoke SetElementCreationCallback if there are candidate elements

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- fixed

People

(Reporter: mstriemer, Assigned: mstriemer)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In bug 1563415 we see some performance regressions from using customElements.setElementCreationCallback() to import our moz- UI widgets using ChromeUtils.importESModule(script, { global: "current" }) similarly to how the non-ESM widgets have been getting imported.

To work around this issue I propose that the SetElementCreationCallback handler be immediately invoked if there are candidate upgrade elements for the component, and defer setting the callback until the DOMContentLoaded event for our ESM based UI widgets.

I'm open to other potential solutions here, but figured I'd post what worked while debugging this issue.

When using SetElementCreationCallback during about:preferences load for
ESM based UI Widgets we are seeing a performance regression vs using
<script type="module"> on the page.

To work around this issue we can delay registering the callback until
the DOMContentLoaded event which improves performance, presumably due to
reduced thrashing from HTML parsing to JS parsing.

With that change however any components that were encountered before the
DOMContentLoaded event will not be loaded or upgraded until the next
time a component of that type is created.

This patch updates the SetElementCreationCallback function to
immediately invoke the callback if there are candidate elemments of that
type to upgrade.

See Also: → 1896837
Pushed by mstriemer@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/97b477552580 Invoke elementCreationCallback if there are elements to upgrade r=smaug
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
Duplicate of this bug: 1463111
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: